<html>
<head>
<meta charset="utf-8">
<title>IP画像/历史事件</title>
<link href="../westcss/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="../westcss/datatables.min.css" rel="stylesheet" type="text/css" />
<link href="../westcss/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../westcss/components.min.css" rel="stylesheet" id="style_components" type="text/css" />
<link href="../westcss/plugins.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../westcss/layer.css">
<!--
<link rel="stylesheet" type="text/css" href="../westcss/jquery.datetimepicker.css"/>
-->
<link rel="stylesheet" href="../westcss/font-awesome.min.css">
<!--	
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">	
-->
</head>
<body>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="col-md-12">
			<div class="portlet light bordered">
					<div class="portlet-title">
						IP画像/历史事件约束
					</div>
					<input type="text" id="attackIp" placeholder="请输入攻击源IP地址" />
					<select id="ipId" onclick="ipfunc();">
						<option value="0" selected>请选择搜索项</option>
						<option value="1">搜索IP画像</option>
						<option value="2">搜索IP历史事件</option>
					</select>
					
			</div>
				
		</div>
	</div>
	<div class="row-fluid">
		<div class="col-md-12" id="ipic">
			<div class="portlet light bordered">
							<div class="portlet-title">
								IP画像详情
							</div>
							<div class="portlet-body">
								<table class="table table-striped table-bordered table-hover" id="sample_1">
									<thead>
										<tr>
											<th> IP地址 </th>
											<th> IP所属位置 </th>
											<th> 注册人组织 </th>
											<th> 注册人国家或地区 </th>
											<th> 电子邮件 </th>
											<th> 团队或个人名称 </th>
											
										</tr>
									</thead>
									<tbody>
									   
									</tbody>
								</table>
							</div>
			</div>
		</div>
	</div>
	<div class="row-fluid" id="iphistory">
		<div class="col-md-12">
			<div class="portlet light bordered">
							<div class="portlet-title">
								IP历史事件
							</div>
							<div class="portlet-body">
								<table class="table table-striped table-bordered table-hover" id="sample_2">
									<thead>
										<tr>
											<th> 事件名称 </th>
											<th> IP事件时间 </th>
											<th> 描述 </th>											
										</tr>
									</thead>
									<tbody>
									   
									</tbody>
								</table>
							</div>
			</div>
		</div>
	</div>
</div>
<script src="../westjs/jquery.min.js" type="text/javascript"></script>
<script src="../westjs/bootstrap.min.js" type="text/javascript"></script>
<script src="../westjs/layer.js"></script>
<script src="../westjs/datatables.min.js" type="text/javascript"></script>
<script src="../westjs/datatables.bootstrap.js" type="text/javascript"></script>
<!--添加全局申请ip-->
    <script src="../gobal_ip/gobal_ip.js" type="text/javascript"></script>
<!--
<script src="../westjs/jquery.datetimepicker.full.js"></script>
-->

<script type="text/javascript">
	$.ajaxSetup({
			async: false
	});
	
	$(document).ready(function() {
		$("#ipic").hide();
		$("#iphistory").hide();
		$('#sample_1').dataTable({
			"pageLength": 2,
			"lengthChange": false,
			"info":false,
			"searching":false,
			"data": "",			
		});
		
	});

	function getTwoDensionArr(dension,len)
	{
		var arr=new Array();
		for(var i=0;i<dension;i++)
		{
			arr[i]=new Array();
			for(var j=0;j<len;j++)
			{
				arr[i][j]="dafault";
			}
		}
		return arr;
	}
	function ipfunc()
	{
		$("#ipId").change(function(){
			value=$("#ipId").val();
			if(value=="1")
				findEv();
			if(value=="2")
				findEvhistory();
		})
	}
	function findEv()
	{
		$("#ipic").show();
		$("#iphistory").hide();
		eventall=getTwoDensionArr(1,6);	
		tmp=[];
/*
		$.ajax({
			url: "../subwest/data/IP.json",
			async: false,//改为同步方式
			type: "GET",
		//	data: { arg: val },
			success: function (data) {
				eventall.length=data.data.length;
				$(data.data).each(function(index,items){
					tmp.push(items.ip);
					tmp.push(items.ipwz);
					tmp.push(items.zcrzz);
					tmp.push(items.zcdz);
					tmp.push(items.dzyj);
					tmp.push(items.hkmc);
					eventall[index]=tmp;
					tmp=[];
				})
			}
		});
*/
		var attackIpStr=$("#attackIp").val();
		//var jsonIpObj={category:"detail",ip:attackIpStr};
		var jsonIpObj={category:"detail",ip:"51.254.209.163"};
		$.get(encodeURI("http://"+global_ip+"/networkassetinfocon/ipStat?param="+JSON.stringify(jsonIpObj)),function(data){
			eventall.length=data.data.length;
			$(data.data).each(function(index,items){
				tmp.push(items.ip);
				tmp.push(items.ipwz);
				tmp.push(items.zcrzz);
				tmp.push(items.zcdz);
				tmp.push(items.dzyj);
				tmp.push(items.hkmc);
				eventall[index]=tmp;
				tmp=[];
			})
		});
		
		$('#sample_1').dataTable({
			"destroy": true,
			"data": eventall,	
			"searching":false,
			"pageLength": 2,
			"lengthChange": false,
			"info":false,
			 buttons: [
				{ extend: 'print', className: 'btn dark btn-outline' },
				{ extend: 'pdf', className: 'btn green btn-outline' },
				{ extend: 'csv', className: 'btn purple btn-outline ' }
			],
			//responsive: true,
			colReorder: {
				reorderCallback: function () {
					console.log( 'callback' );
				}
			},
			"order": [
				[0, 'asc']
			],
			"dom": "<'row' <'col-md-12'B>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>"
		});		
	}
	function findEvhistory()
	{
		$("#ipic").hide();
		$("#iphistory").show();
		
		eventhis=getTwoDensionArr(1,3);	
		tmp=[];
/*
		$.ajax({
			url: "../subwest/data/IP_history.json",
			async: false,//改为同步方式
			type: "GET",
		//	data: { arg: val },
			success: function (data) {
				eventhis.length=data.data.length;
				$(data.data).each(function(index,items){
					tmp.push(items.name);
					tmp.push(items.sj);
					tmp.push(items.ms);

					eventhis[index]=tmp;
					tmp=[];
				})
			}
		});
*/
		var attackIpStr=$("#attackIp").val();
		//var jsonIpObj={category:"event",ip:attackIpStr};
		var jsonIpHisObj={category:"event",ip:"51.254.209.163"};
		$.get(encodeURI("http://"+global_ip+"/networkassetinfocon/ipStat?param="+JSON.stringify(jsonIpHisObj)),function(data){
			eventhis.length=data.data.length;
			$(data.data).each(function(index,items){
				tmp.push(items.sjmc);
				tmp.push(items.sj);
				tmp.push(items.ms);
				eventhis[index]=tmp;
				tmp=[];
			})
		});
			
		$('#sample_2').dataTable({
			"destroy": true,
			"data": eventhis,	
			"searching":false,
			"pageLength": 2,
			"lengthChange": false,
			"info":false,
			 buttons: [
				{ extend: 'print', className: 'btn dark btn-outline' },
				{ extend: 'pdf', className: 'btn green btn-outline' },
				{ extend: 'csv', className: 'btn purple btn-outline ' }
			],
			//responsive: true,
			colReorder: {
				reorderCallback: function () {
					console.log( 'callback' );
				}
			},
			"order": [
				[0, 'asc']
			],
			"dom": "<'row' <'col-md-12'B>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>"
		});		
	}
		
</script>
</body>
<html>